202510241126 - x402

Main Topic

Question: What is x402, and how does it turn HTTP 402 into a practical payment layer for APIs and agents?

x402 is an open standard for internet-native, pay-per-use payments over HTTP. It uses the historically reserved HTTP status code 402 Payment Required to create a consistent challenge-response flow where a client can be asked to pay, present a payment, and then retry the request.

The core idea is that an API endpoint can respond with a machine-readable payment request (what asset/network to pay with, how much, and where), and the client can satisfy it in a standardized way without pre-existing billing accounts or subscriptions. This is especially useful for:

In practice, most x402 implementations today are built around onchain payments (for example, paying in a stablecoin on a supported network), but the standard is meant to describe the HTTP-level interface so different payment rails can plug in over time.

Typical high-level flow:

  1. Client requests a protected resource.
  2. Server responds with 402 and includes the payment requirement in headers/body.
  3. Client performs the payment and attaches proof/payment information to a follow-up request.
  4. Server verifies the payment and returns the original response (200).

Where x402 is meaningful is not the existence of payments, but the standardization of how payments are requested and presented at the protocol boundary (HTTP), enabling broad interoperability between clients, gateways, and services.

🌲 Branching Questions

Q: How does an x402 HTTP exchange work end-to-end, and what should an implementation pay attention to?

A minimal implementation needs to define:

The common pattern is that the server creates a short-lived payment intent and returns 402 with enough data for the client to pay and prove payment. After the client pays, it retries the request with an Authorization-like header or a structured payment header that includes the proof. The server then validates the proof against its policy:

If validation passes, the server returns the protected content. If not, it may return 402 again (with updated instructions), 401/403 depending on policy, or 5xx on verification failure.

For reliability, implementations usually need to handle chain reorg risk, confirmation requirements, and eventual consistency. Many services will accept a transaction as paid only after N confirmations.

Q: What are the main security and product risks when using x402 for API monetization?

Key risks and mitigations:

From a product perspective, the biggest risk is fragmentation: if each service uses a slightly different schema, the standard does not deliver interoperability. That is why the spec and canonical libraries matter.

References